package leetcode.hot100;

import java.util.HashMap;

public class number128 {
    public static void main(String[] args) {
        System.out.println(longestConsecutive(new int[]{100,4,200,1,3,2}));
    }
    public static int longestConsecutive(int[] nums) {
        int re=0;
        HashMap<Integer,Integer> map=new HashMap();
        for(int i:nums){
            map.put(i,1);
        }
        for (int i:nums){
            int nowMax=1;
            while(map.containsKey(i-1)){
                nowMax++;
                i--;
            }
            re=Math.max(re,nowMax);
        }
        return re;
    }
}
